package com.bangbang.blog.controller;


import com.bangbang.blog.pojo.TbCollect;
import com.bangbang.blog.service.impl.TbCollectServiceImpl;
import com.bangbang.configresult.Result;
import com.bangbang.configresult.ResultEnum;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 收藏表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-08-12
 */
@RestController
@RequestMapping("/blog/tbCollect")
public class TbCollectController {

    @Autowired
    private TbCollectServiceImpl tbCollectService;


    //新增

    @PostMapping
    @ApiOperation("收藏添加方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tbCollect",value = "收藏实体类",required = true,paramType = "body")
    })
    public Result insert(@RequestBody TbCollect tbCollect){
        tbCollectService.insert(tbCollect);
        return Result.buildResult(ResultEnum.SUCCESS);
    }

    //修改
    @PutMapping
    @ApiOperation("收藏修改方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tbCollect",value = "收藏实体类",required = true,paramType = "body")
    })
    public Result update(@RequestBody TbCollect tbCollect){
        tbCollectService.updateById(tbCollect);
        return Result.buildResult(ResultEnum.SUCCESS);
    }

    //删除
    @DeleteMapping
    @ApiOperation("收藏删除方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "collId",value = "收藏Id",required = true,paramType = "query")
    })
    public Result delete(@RequestParam(required = true)Long collId){
        tbCollectService.delete(collId);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
    //查询
    @GetMapping
    @ApiOperation("收藏查询方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "collId",value = "收藏Id",required = true,paramType = "query")
    })
    public Result select(@RequestParam(required = true)Long collId){
            tbCollectService.select(collId);
            return Result.buildResult(ResultEnum.SUCCESS);
    }
}

